The Movie Toolbox provides a number of functions that allow you to work with time structures. This section describes those functions.
All of these functions work with time structures (see "The Time Structure" for a complete discussion of the time structure). You can use time structures to represent either time values or durations. Time values specify a point in time, relative to a given time base. Durations specify a span of time, relative to a given time scale. Durations are represented by time structures that have the time base set to 0 (that is, the base field in the time structure is set to nil ).
You can use the ConvertTime function to convert a time you obtain from one time base into a time that is relative to another time base. Similarly, you can use the ConvertTimeScale function to convert a time from one time scale to another.
You can add two times by calling the AddTime function; you can subtract two times with the SubtractTime function.
The AddTime function adds two times. You must specify the times in time structures.
pascal void AddTime (TimeRecord *dst, const TimeRecord *src);
If these times are relative to different time scales or time bases, the AddTime function converts the times as appropriate to yield reasonable results. However, the time bases for both time values must rely on the same time source.
The result value is formatted based on the operands as follows:
The SubtractTime function subtracts one time from another. You must specify the times in time structures.
pascal void SubtractTime (TimeRecord *dst, const TimeRecord *src);
If these times are relative to different time scales or time bases, the SubtractTime function converts the times as appropriate to yield reasonable results. However, the time bases for both time values must rely on the same time source.
The result value is formatted based on the operands as follows:
You can convert a time you obtain from one time base into a time that is relative to another time base by calling the ConvertTime function. Both time bases must rely on the same time source. You must specify the time to be converted in a time structure.
pascal void ConvertTime (TimeRecord *inout, TimeBase newBase);
You can convert a time from one time scale into a time that is relative to another time base by calling the ConvertTimeScale function. You must specify the time to be converted in a time structure.
pascal void ConvertTimeScale (TimeRecord *inout,
TimeScale newScale);
The ConvertTimeScale function does not include the rate associated with the time value in the conversion; therefore, you should use this function when you want to convert time durations, but not when converting time values. Use the ConvertTime function (described in the previous section) to convert time values.